package com.arong.swing.db.dao;

import java.sql.SQLException;

import com.arong.swing.db.JDBCUtils;
import com.arong.swing.db.entity.KeyPerson;
import com.arong.swing.exception.AppException;
import com.arong.swing.exception.SysException;
public class KeyPersonSDAO  extends BaseDAO {
	/*public KeyPersonSDAO(){
		this(DB_PACKAGEDATA);
	}*/
	public KeyPersonSDAO(String dbFile){
		super(dbFile);
	}
	public KeyPersonSDAO(JDBCUtils jdbcUtils){
		super(jdbcUtils);
	}
	public String getCreateTableSql(){
		return "CREATE TABLE IF NOT EXISTS "+
				"KEY_PERSON("+
						 " SFZH  VARCHAR2(32) PRIMARY KEY,"+//身份证号
						 " RYLB VARCHAR2(256),"+//人员类别
						 " CLFS VARCHAR2(256),"+//处理方式
						 " AQMS VARCHAR2(512),"+//案情描述
						 " BKLXR VARCHAR2(512),"+//布控联系人
						 " BKLXFS VARCHAR2(512),"+//布控联系方式
						 " RWMC VARCHAR2(512),"+//任务名称
						 " RWID VARCHAR2(512),"+//任务ID
						 " PFIRSTID VARCHAR2(512),"+//布控包ID
						 " PVERID VARCHAR2(512)"+//布控包版本ID
						 ")";
		
	}
	
	/**
	 * 插入
	 * @param entity
	 * @return
	 * @throws SysException, AppException
	 */
	public  int insert(KeyPerson entity) throws SysException,AppException {
		int i=0;
		try {
		 			i= jdbcUtils.insert(entity);
		} catch (SQLException e) {
			throw new SysException("add error", e);
		}
		return i;
	}

	/**
	 * 查询对象
	 * @param entity
	 * @return
	 * @throws SysException, AppException
	 */
	public  KeyPerson queryBean(String sfzh) throws SysException,AppException {
		KeyPerson res=null;
	    try {
	    	Object[] params ={sfzh};
			res=  jdbcUtils.queryBean("SELECT SFZH,RYLB,CLFS,AQMS,BKLXR,BKLXFS,RWMC,RWID,PFIRSTID,PVERID FROM KEY_PERSON WHERE SFZH=?", KeyPerson.class,params);
		} catch (SQLException e) {
			throw new SysException("queryBean对象查询 error",e);
		}
		return   res;
	}
	
}

